package com.seth.myapplication.helper;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

/**
 * Created by Seth on 2017/10/17.
 */

public class SetStatusTabHeight {

    private LinearLayout mLinearLayout;
    private Context mContext;

    public SetStatusTabHeight(LinearLayout relativeLayout,Context context){
        mLinearLayout = relativeLayout;
        mContext = context;
    }
    public void setRelativeLayout(){

                /*动态获取高度*/
        int height = getStatusBarHeight(mContext);
        /*设置高度*/
        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mLinearLayout.getLayoutParams();
        params.height = height;
        mLinearLayout.setLayoutParams(params);
    }



    /**
     * 获取状态栏高度
     * @param context
     * @return
     */
    private int getStatusBarHeight(Context context) {
        int result = 0;
        int resourceId = context.getResources().getIdentifier("status_bar_height", "dimen", "android");
        if (resourceId > 0) {
            result = context.getResources().getDimensionPixelSize(resourceId);
        }
        return result;
    }

}
